package com.will.seed.configuration;

import com.will.seed.common.TestWebSocketHandler;
import com.will.seed.common.HandshakeInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * Created by Administrator on 2018/8/1.
 */

@Component
@EnableWebSocket
public class WebsocketConfiguration implements WebSocketConfigurer {

    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new TestWebSocketHandler(), "/websocket").addInterceptors(new HandshakeInterceptor()).setAllowedOrigins("*");
    }
}
